(() => {
  // 存取器
  // ts支持getter和setter来截取对象成员的访问，可以帮助有效控制对象属性成员的访问

  class Person {
    firstName: string
    lastName: string
    constructor(firstName: string, lastName: string) {
      this.firstName = firstName
      this.lastName = lastName
    }

    get fullName() {
      return this.firstName + this.lastName
    }

    set fullName(val) {
      this.firstName = val.split('_')[0]
      this.lastName = val.split('_')[1]
    }

  }

  const person = new Person('dandan', 'liu')
  console.log(person.fullName)

  person.fullName = 'zhipeng_xie'

  console.log(person.fullName)

})()